package com.cloudweb.oa.visual;

import cn.js.fan.db.ResultIterator;
import cn.js.fan.db.ResultRecord;
import cn.js.fan.util.StrUtil;
import com.cloudwebsoft.framework.db.JdbcTemplate;
import com.cloudwebsoft.framework.util.LogUtil;
import com.redmoon.oa.message.MessageDb;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

@Slf4j
@Component
public class NoticeService {
    public int getUnreadCount(String userName) {
        String sql = "select count(*) from ft_notice_receipt where receipt_status = '0' and user_name="+ StrUtil.sqlstr(userName);
        JdbcTemplate jt = new JdbcTemplate();
        ResultIterator ri;
        try {
            ri = jt.executeQuery(sql);
            if (ri.hasNext()) {
                ResultRecord rr = ri.next();
                return rr.getInt(1);
            }
        } catch (SQLException e) {
            e.printStackTrace();
            LogUtil.getLog(getClass()).error(e);
        }
        return 0;
    }

}
